package com.geostar.constructionland.analyse.mapper.sptalyresult;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.geostar.constructionland.analyse.entity.alyresult.tzhdlgdfx.AlyResultDlfx;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author yelll
 * @since 2020-6-11 14:25
 **/
public interface AlyResultDlfxMapper extends BaseMapper<AlyResultDlfx> {
    @Select(" select t.* ,'违法建设用地还原' as hylx  from (" +
            " select b.dlid,b.qsdwdm,b.qsdwmc,b.qsxz,b.dlbm,b.dlmc,b.dkbs,b.fxbs,b.dlmj,b.xzdwmj,b.tkmj,b.ktzmj,b.qsxz_real,b.kcdlbm," +
            " b.zdxxid,b.bphxfxid,b.dllx,b.yzxzdwmj,b.mongo_id," +
            " (select max(d.zymj) from jsyd_fx_dlfx_tj_tzh d where d.dlid = b.dlid) as tbdlmj," +
            " (select max(d.ktzmj) from jsyd_fx_dlfx_tj_tzh d where d.dlid = b.dlid) as ktzmj_tj " +
            " from jsyd_fx_dlfx b where fxbs = #{fxbs,jdbcType=VARCHAR}) t  " +
            " inner join  jsyd_dlbm a" +
            " on t.dlbm = a.dlbm3" +
            " where (a.tjbm1 = '1' and t.bphxfxid = 'false')  " +
            " union " +
            " select t.*,'可调整还原' as hylx   from (" +
            " select b.dlid,b.qsdwdm,b.qsdwmc,b.qsxz,b.dlbm,b.dlmc,b.dkbs,b.fxbs,b.dlmj,b.xzdwmj,b.tkmj,b.ktzmj,b.qsxz_real,b.kcdlbm," +
            " b.zdxxid,b.bphxfxid,b.dllx,b.yzxzdwmj,b.mongo_id," +
            " (select max(d.zymj) from jsyd_fx_dlfx_tj_tzh d where d.dlid = b.dlid) as tbdlmj," +
            " (select max(d.ktzmj) from jsyd_fx_dlfx_tj_tzh d where d.dlid = b.dlid) as ktzmj_tj " +
            " from jsyd_fx_dlfx b where fxbs = #{fxbs,jdbcType=VARCHAR}) t  " +
            " inner join  jsyd_dlbm a" +
            " on t.dlbm = a.dlbm3" +
            " where  t.ktzmj_tj > 0   " +
            " union" +
            " select t.*,'设施农用地还原' as hylx  from (" +
            " select b.dlid,b.qsdwdm,b.qsdwmc,b.qsxz,b.dlbm,b.dlmc,b.dkbs,b.fxbs,b.dlmj,b.xzdwmj,b.tkmj,b.ktzmj,b.qsxz_real,b.kcdlbm," +
            " b.zdxxid,b.bphxfxid,b.dllx,b.yzxzdwmj,b.mongo_id," +
            " (select max(d.zymj) from jsyd_fx_dlfx_tj_tzh d where d.dlid = b.dlid) as tbdlmj," +
            " (select max(d.ktzmj) from jsyd_fx_dlfx_tj_tzh d where d.dlid = b.dlid) as ktzmj_tj " +
            " from jsyd_fx_dlfx b where fxbs = #{fxbs,jdbcType=VARCHAR}) t  " +
            " inner join  jsyd_dlbm a" +
            " on t.dlbm = a.dlbm3" +
            " where t.dlbm = '122' " +
            "")
    List<AlyResultDlfx> getMmjjsDkxx(@Param("fxbs")String fxbs);
}
